﻿<Page
    x:Class="EmprestaAE.MVVM.View.DatePickerView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:EmprestaAE.MVVM.View"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:viewmodel="using:EmprestaAE.MVVM.ViewModel"
    xmlns:converters="using:EmprestaAE.Common"
    mc:Ignorable="d">

    <!--<Page.Transitions>
        <TransitionCollection>
            <EntranceThemeTransition/>
        </TransitionCollection>
    </Page.Transitions>-->

    <Page.Resources>
        <viewmodel:DatePickerVM x:Key="datepickervm"/>
        <converters:ConverterDateToString x:Key="DateToStringConverter"/>
    </Page.Resources>

    <Grid Background="{StaticResource ApplicationBackgroundColor}"
          DataContext="{Binding Source={StaticResource datepickervm}, Path=Instance}">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="6*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <!-- back button -->
        <Grid Grid.Column="0" 
              Grid.Row="0">
            <Button Style="{StaticResource BackButtonStyle}"
                    Grid.Row="0"
                    Grid.Column="0"
                    Command="{Binding NavigationService.GoBackCommand}">
            </Button>
        </Grid>

        <!-- title -->
        <Grid Grid.Row="0"
              Grid.Column="1">
            <TextBlock Style="{StaticResource PageHeaderTextStyle}"
                       Text="{StaticResource DatePickerViewTitle}"
                       Grid.Column="1"
                       Grid.Row="0"/>
        </Grid>

        <!-- content -->
        <Grid Grid.Column="1"
              Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="8*"/>
                <ColumnDefinition Width="8*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="8*"/>
                <RowDefinition Height="12*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- due date data -->
            <Grid Grid.Column="0"
                  Grid.Row="0"
                  Grid.ColumnSpan="2"
                  Margin="10"
                  Background="{StaticResource BackgroundButton}">
                <TextBlock Text="{Binding Date, Converter={StaticResource DateToStringConverter}}"
                           VerticalAlignment="Stretch"
                           HorizontalAlignment="Stretch"                           
                           FontSize="200"
                           TextAlignment="Center"/>
            </Grid>

            <!-- day / month / year -->
            <Grid Grid.Column="0"
                  Grid.Row="1"
                  Grid.ColumnSpan="2"
                  Margin="10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Slider Grid.Row="0"
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Center"
                        Maximum="{Binding MaximumLendingTime}"
                        Minimum="{Binding MinimumLendingTime}"                            
                        Value="{Binding LendingTime, Mode=TwoWay}"                            
                        StepFrequency="1" Style="{StaticResource S_SliderDatePicker}"/>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>                            
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" 
                                Content="-"                                
                                Style="{StaticResource S_ButtonIncreaseDecrease}"
                                Command="{Binding DecreaseLendingTimeCommand}"/>
                        <Button Grid.Column="1" 
                                Content="+"
                                Style="{StaticResource S_ButtonIncreaseDecrease}"
                                Command="{Binding IncreaseLendingTimeCommand}"/>                        
                    </Grid>
                    <Grid Grid.Row="2">
                        <Button Grid.Column="1" 
                                Content="pronto"
                                HorizontalAlignment="Center"
                                Style="{StaticResource S_ButtonIncreaseDecrease}"
                                Command="{Binding PickDateCommand}"/>

                    </Grid>
                </Grid>
                
            </Grid>

            <!-- increase / decrease -->
            <Grid Grid.Column="1"
                  Grid.Row="1"
                  Margin="10"
                  >
                
            </Grid>

        </Grid>
    </Grid>
</Page>